package top.yangyitao.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import top.yangyitao.dao.PermissionRepository;
import top.yangyitao.entity.Permission;
import top.yangyitao.service.PermissionService;

@Service
public class PermissionServiceImpl implements PermissionService {

	@Autowired
	private PermissionRepository permissionDao;
	
	@Override
	public void save(Permission permission) {
		permissionDao.saveAndFlush(permission);
	}

	@Override
	public void save(List<Permission> permissions) {
		permissionDao.saveAll(permissions);
		permissionDao.flush();
	}

	@Override
	public void delete(Permission permission) {
		permissionDao.delete(permission);
	}

	@Override
	public void delete(List<Permission> permissions) {
		permissionDao.deleteAll(permissions);
	}

	@Override
	public List<Permission> findAll() {
		return permissionDao.findAll();
	}

	@Override
	public Permission getOne(long id) {
		return permissionDao.findById(id).get();
	}

	@Override
	public List<Permission> findAllById(List<Long> ids) {
		return permissionDao.findAllById(ids);
	}

}
